package br.inf.solutions.apresentacoes.ssp.control.hierarchy;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import br.com.vexillum.model.IActivatedEntity;
import br.com.vexillum.util.Return;
import br.inf.solutions.apresentacoes.ssp.control.BaseController;
import br.inf.solutions.apresentacoes.ssp.model.hierarchy.HierarchyStructType;

@Service
@Scope("prototype")
public class HierarchyStructTypeController extends BaseController<HierarchyStructType>{

	public HierarchyStructTypeController() {
		super(HierarchyStructType.class);
	}
	
	@Override
	public Return listAll() {
		String sql = "FROM " + classEntity.getSimpleName() + " WHERE active = true AND id > 1 ORDER BY name";
		if(data.get("entity") == null || (((IActivatedEntity) data.get("entity")).getActive() == null) || !((IActivatedEntity) data.get("entity")).getActive()){
			sql = sql.replace("active = true AND ", "");
		}
		data.put("sql", sql);
		return super.searchByHQL();
	}
}
